package logic

import (
	"bawei_shop/user_srv/internal/svc"
	"bawei_shop/user_srv/model/mysql"
	"bawei_shop/user_srv/user"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type PingLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
	return &PingLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PingLogic) Ping(in *user.CreateRealNameRequest) (*user.CreateRealNameResponse, error) {
	u := mysql.UserRealName{
		UserID:   in.UserId,
		RealName: in.RealName,
		IdCard:   in.IdCard,
	}
	err := u.Create()
	if err != nil {
		logx.Error("实名信息创建失败", err)
		return nil, err
	}

	return &user.CreateRealNameResponse{}, nil
}
